import cgi
import os
from google.appengine.ext import webapp
from google.appengine.ext.webapp import template
from google.appengine.ext.webapp.util import run_wsgi_app
from google.appengine.ext import db
from eutax.robopuzzle.core import database
from eutax.robopuzzle.web.main import MainPage
from eutax.robopuzzle.web.main import Maps
from eutax.robopuzzle.web.main import MapCreator
from eutax.robopuzzle.web.main import IDE
from eutax.robopuzzle.web.main import TaskList
from eutax.robopuzzle.web.main import MapPresentation
from eutax.robopuzzle.web.test import ProgramTester
from eutax.robopuzzle.web import util

application = webapp.WSGIApplication(
                                     [
                                      ('/', MainPage),
                                      ('/maps', Maps),
                                      ('/maps/create', MapCreator),
                                      ('/maps/show/.*', MapPresentation),
                                      ('/ide|/ide/.*', IDE),
                                      ('/tasklist', TaskList),
                                      ('/test/program', ProgramTester),
                                      ],
                                     debug=True)

def main():
  action = database.Action()
  action.actionKey = 'f'
  action.name = 'Forward'
  action.put()
  action = database.Action()
  action.actionKey = 'l'
  action.name = 'LeftTurn'
  action.put()
  action = database.Action()
  action.actionKey = 'r'
  action.name = 'RightTurn'
  action.put()

  tile = database.Tile()
  tile.tileKey = 'n'
  tile.name = 'Normal'
  tile.design = 'normal'
  tile.put()
  tile = database.Tile()
  tile.tileKey = 'a'
  tile.name = 'Activateable'
  tile.design = 'activateable'
  tile.put()
  
  map = database.Map()
  map.name = 'First'
  map.data = 'n, a, n 2'
  map.put()
  
  map = database.Map()
  map.name = 'Second'
  map.data = 'n 2, a, a'
  map.put()
  
  run_wsgi_app(application)

if __name__ == "__main__":
  main()